import { InjectionKey, Ref } from "vue/dist/vue.js";
export type switchShow = () => void
export type loginType = () => void
export type getUserInfo = () => void
export type setSrcAndPlay = (history: musicHistory) => void
export type play = () => void;
export type deleteSingerMusic = (index: number) => void;
export type popMessage = (message: string, type: MessageType, callback?: Function) => void;
export type addMusicToList = (history: musicHistory) => void;
export type imageUpload = (file: File) => string;
export const isShowKey: InjectionKey<Ref<boolean>> = Symbol();
export const switchLoginModelShowKey: InjectionKey<switchShow> = Symbol();
export const loginKey: InjectionKey<loginType> = Symbol();
export const getUserInfoKey: InjectionKey<getUserInfo> = Symbol();
export const urlKey: InjectionKey<Ref<string>> = Symbol();
export const popMessageKey: InjectionKey<popMessage> = Symbol()
export const messageQueueKey: InjectionKey<Message[]> = Symbol();
export const playKey: InjectionKey<play> = Symbol();
export const playerKey: InjectionKey<HTMLAudioElement> = Symbol();
export const addMusicToListKey: InjectionKey<addMusicToList> = Symbol();
export const setSrcAndPlayKey: InjectionKey<setSrcAndPlay> = Symbol();
export const playListKey: InjectionKey<Ref<musicHistory[]>> = Symbol();
export const playIndexKey: InjectionKey<Ref<number>> = Symbol();
export const nextMusicKey: InjectionKey<() => void> = Symbol();
export const lastMusicKey: InjectionKey<() => void> = Symbol();
export const playingMusicDurationKey: InjectionKey<Ref<number>> = Symbol();
export const updatePlayerSrcAndPlayKey: InjectionKey<(musicId: string) => void> = Symbol();
export const deleteSingerMusicKey: InjectionKey<deleteSingerMusic> = Symbol();
export const deleteAllMusicKey: InjectionKey<() => void> = Symbol()
export const switchPersonCenterShowKey: InjectionKey<() => void> = Symbol();
export const getPlayingMusicKey: InjectionKey<() => any> = Symbol()
export const routerToMoreMusicListKey: InjectionKey<() => void> = Symbol()
export const collectAllKey: InjectionKey<() => void> = Symbol()
export interface User {
    id: string,
    phone?: string,
    avatar: string,
    account?: string,
    name: string,
    level?: Number,
    follow?: Number,
    follower?: Number,
    introduce?: string
}
export interface UserDto {
    id: string,
    avatar: string,
    account: string,
    password: string,
    name: string,
    phone: number,
    email: string,
    introduce: string,
    type: string,
    musicListCount: number,
    fans: number
    followed: boolean
}
export type MusicList = {
    id?: string,
    creatorName?: string,
    creatorId?: string,
    title?: string,
    introduce: string,
    playCount?: number,
    image?: string,
    createDate?: string,
    shareCount?: number,
    musicList?: Music[],
    singerList?: User[],
    musicNum?: number
}
export type Music = {
    musicId: string,
    duration: number,
    format?: string,
    playCount?: number,
    publishDate?: string,
    src: string,
    style?: string,
    title: string,
    image?: string,
    introduce?: string,
    singerName?: string,
    singerId?: string,
    cdname?: string
}
export type Message = {
    message: string,
    type: MessageType,
    callback?: Function
}
export interface SocialInfo {
    concerns: number,
    fans: number,
    post: number
}
export interface playerStyle {
    last: number,
    play: number,
    next: number
}
export interface musicHistory {
    id: string,
    url: string,
    name: string,
    duration: number,
    singerId?: string,
    singerName: string,
    image: string,
    from?: 'musicList' | 'cd' | 'singer' | 'single' | 'search',
    typeId?: string
}
export interface Post {
    id: string,
    content: string,
    likes: number,
    shareCount: number,
    createTime: number[],
    commentCount: number,
    userId: string,
    imageList: string[],
    // type: string,
    // typeId: string,
    avatar: string,
    username: string,
}

export class PostDto implements Post {
    id: string = '';
    content: string = '';
    likes: number = 0;
    shareCount: number = 0;
    createTime: number[] = [];
    commentCount: number = 0;
    userId: string = '';
    imageList: string[] = [];
    // type: string = '';
    // typeId: string = '';
    avatar: string = '';
    username: string = '';
    showComment: boolean = false
}

export interface Comment {
    id: string,
    content: string,
    likes: number,
    createTime: number[],
    userId: string,
    type?: string,
    typeId?: string,
    name: string,
    avatar: string,
    commentedId: string,
    commented?: Comment,
    rowNo?: number
}
export interface FollowDto {
    user: User,
    socialInfo: SocialInfo
}
export interface SingerPageInfo {
    userId: string,
    introduce: string,
    image: string
}
export interface PageInfo<T> {
    total: number,
    list: T[],
    pageNum: number,
    pageSize: number,
    size: number,
    startRow: number,
    endRow: number,
    pages: number,
    prePage: number,
    nextPage: number,
    isFirstPage: boolean,
    isLastPage: boolean,
    hasPreviousPage: boolean,
    hasNextPage: boolean,
    navigatePages: number,
    navigatepageNums: number[],
    navigateFirstPage: number,
    navigateLastPage: number

}
export interface Play {
    musicId: string,
    playCount: number
}
export type MessageType = 'success' | 'error' | 'warning' | 'info'
export function isValidKey(
    key: string | number | symbol,
    object: object
): key is keyof typeof object {
    return key in object;
}

export interface MusicDto {
    music: Music
    user: User
}
